using GraphProcessor;
using IQIGame.Onigao.Logic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
	[System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.PlayOrStopEntityEffect, typeof(LevelServiceGraph))]
    public class LevelServiceExecutionNode_PlayOrStopEntityEffect : LevelServiceExecutionNode
    {
		protected override ServiceExecutionType mServiceType => ServiceExecutionType.PlayOrStopEntityEffect;
        public override string name => LevelEditorConst.PlayOrStopEntityEffect;
# region property
        [Output("目标", false)] public EditorLevelServiceTargetSetter tagOrMcid;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.PlayOrStopEntityEffect, "Resource表ID")]
        public int effectCid;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.PlayOrStopEntityEffect, "EntityBindPoint表ID")]
        public int bindPointCid;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.PlayOrStopEntityEffect, "是否是添加")]
        public bool isAdd;
# endregion property
		protected override LevelServiceCustomConfig CreateConfig()
        {
        	LevelServiceExecutionCustom_PlayOrStopEntityEffect rConfig;
# region CreateConfig
            rConfig = new LevelServiceExecutionCustom_PlayOrStopEntityEffect
            {
                effectCid = this.effectCid,
                bindPointCid = this.bindPointCid,
                isAdd = this.isAdd,
            };
            this.tagOrMcid = new EditorLevelServiceTargetSetter((x) => rConfig.tagOrMcid = x);
# endregion CreateConfig
            return rConfig;
        }

        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
# region OnSync
            if (tempNode is LevelServiceExecutionNode_PlayOrStopEntityEffect rNode)
            {
                this.effectCid = rNode.effectCid;
                this.bindPointCid = rNode.bindPointCid;
                this.isAdd = rNode.isAdd;
            }
            if (newConfig.customConfig is LevelServiceExecutionCustom_PlayOrStopEntityEffect rConfig)
            {
                this.SyncTarget(rConfig.tagOrMcid, nameof(tagOrMcid));
            }
# endregion OnSync
        }
    }
}